import 'package:safetymonitor/generated/json/base/json_convert_content.dart';
import 'package:safetymonitor/app/data/entities/auth/get_permission_info_entity.dart';

GetPermissionInfoEntity $GetPermissionInfoEntityFromJson(Map<String, dynamic> json) {
  final GetPermissionInfoEntity getPermissionInfoEntity = GetPermissionInfoEntity();
  final GetPermissionInfoUser? user = jsonConvert.convert<GetPermissionInfoUser>(json['user']);
  if (user != null) {
    getPermissionInfoEntity.user = user;
  }
  final List<String>? roles = (json['roles'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (roles != null) {
    getPermissionInfoEntity.roles = roles;
  }
  final List<GetPermissionInfoMenus>? menus = (json['menus'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<GetPermissionInfoMenus>(e) as GetPermissionInfoMenus).toList();
  if (menus != null) {
    getPermissionInfoEntity.menus = menus;
  }
  return getPermissionInfoEntity;
}

Map<String, dynamic> $GetPermissionInfoEntityToJson(GetPermissionInfoEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['user'] = entity.user?.toJson();
  data['roles'] = entity.roles;
  data['menus'] = entity.menus?.map((v) => v.toJson()).toList();
  return data;
}

extension GetPermissionInfoEntityExtension on GetPermissionInfoEntity {
  GetPermissionInfoEntity copyWith({
    GetPermissionInfoUser? user,
    List<String>? roles,
    List<GetPermissionInfoMenus>? menus,
  }) {
    return GetPermissionInfoEntity()
      ..user = user ?? this.user
      ..roles = roles ?? this.roles
      ..menus = menus ?? this.menus;
  }
}

GetPermissionInfoUser $GetPermissionInfoUserFromJson(Map<String, dynamic> json) {
  final GetPermissionInfoUser getPermissionInfoUser = GetPermissionInfoUser();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    getPermissionInfoUser.id = id;
  }
  final String? nickname = jsonConvert.convert<String>(json['nickname']);
  if (nickname != null) {
    getPermissionInfoUser.nickname = nickname;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    getPermissionInfoUser.avatar = avatar;
  }
  final int? deptId = jsonConvert.convert<int>(json['deptId']);
  if (deptId != null) {
    getPermissionInfoUser.deptId = deptId;
  }
  return getPermissionInfoUser;
}

Map<String, dynamic> $GetPermissionInfoUserToJson(GetPermissionInfoUser entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['nickname'] = entity.nickname;
  data['avatar'] = entity.avatar;
  data['deptId'] = entity.deptId;
  return data;
}

extension GetPermissionInfoUserExtension on GetPermissionInfoUser {
  GetPermissionInfoUser copyWith({
    int? id,
    String? nickname,
    String? avatar,
    int? deptId,
  }) {
    return GetPermissionInfoUser()
      ..id = id ?? this.id
      ..nickname = nickname ?? this.nickname
      ..avatar = avatar ?? this.avatar
      ..deptId = deptId ?? this.deptId;
  }
}

GetPermissionInfoMenus $GetPermissionInfoMenusFromJson(Map<String, dynamic> json) {
  final GetPermissionInfoMenus getPermissionInfoMenus = GetPermissionInfoMenus();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    getPermissionInfoMenus.id = id;
  }
  final int? parentId = jsonConvert.convert<int>(json['parentId']);
  if (parentId != null) {
    getPermissionInfoMenus.parentId = parentId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    getPermissionInfoMenus.name = name;
  }
  final String? path = jsonConvert.convert<String>(json['path']);
  if (path != null) {
    getPermissionInfoMenus.path = path;
  }
  final String? component = jsonConvert.convert<String>(json['component']);
  if (component != null) {
    getPermissionInfoMenus.component = component;
  }
  final String? componentName = jsonConvert.convert<String>(json['componentName']);
  if (componentName != null) {
    getPermissionInfoMenus.componentName = componentName;
  }
  final String? icon = jsonConvert.convert<String>(json['icon']);
  if (icon != null) {
    getPermissionInfoMenus.icon = icon;
  }
  final bool? visible = jsonConvert.convert<bool>(json['visible']);
  if (visible != null) {
    getPermissionInfoMenus.visible = visible;
  }
  final bool? keepAlive = jsonConvert.convert<bool>(json['keepAlive']);
  if (keepAlive != null) {
    getPermissionInfoMenus.keepAlive = keepAlive;
  }
  final bool? alwaysShow = jsonConvert.convert<bool>(json['alwaysShow']);
  if (alwaysShow != null) {
    getPermissionInfoMenus.alwaysShow = alwaysShow;
  }
  final List<GetPermissionInfoMenusChildren>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<GetPermissionInfoMenusChildren>(e) as GetPermissionInfoMenusChildren).toList();
  if (children != null) {
    getPermissionInfoMenus.children = children;
  }
  return getPermissionInfoMenus;
}

Map<String, dynamic> $GetPermissionInfoMenusToJson(GetPermissionInfoMenus entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['parentId'] = entity.parentId;
  data['name'] = entity.name;
  data['path'] = entity.path;
  data['component'] = entity.component;
  data['componentName'] = entity.componentName;
  data['icon'] = entity.icon;
  data['visible'] = entity.visible;
  data['keepAlive'] = entity.keepAlive;
  data['alwaysShow'] = entity.alwaysShow;
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  return data;
}

extension GetPermissionInfoMenusExtension on GetPermissionInfoMenus {
  GetPermissionInfoMenus copyWith({
    int? id,
    int? parentId,
    String? name,
    String? path,
    String? component,
    String? componentName,
    String? icon,
    bool? visible,
    bool? keepAlive,
    bool? alwaysShow,
    List<GetPermissionInfoMenusChildren>? children,
  }) {
    return GetPermissionInfoMenus()
      ..id = id ?? this.id
      ..parentId = parentId ?? this.parentId
      ..name = name ?? this.name
      ..path = path ?? this.path
      ..component = component ?? this.component
      ..componentName = componentName ?? this.componentName
      ..icon = icon ?? this.icon
      ..visible = visible ?? this.visible
      ..keepAlive = keepAlive ?? this.keepAlive
      ..alwaysShow = alwaysShow ?? this.alwaysShow
      ..children = children ?? this.children;
  }
}

GetPermissionInfoMenusChildren $GetPermissionInfoMenusChildrenFromJson(Map<String, dynamic> json) {
  final GetPermissionInfoMenusChildren getPermissionInfoMenusChildren = GetPermissionInfoMenusChildren();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    getPermissionInfoMenusChildren.id = id;
  }
  final int? parentId = jsonConvert.convert<int>(json['parentId']);
  if (parentId != null) {
    getPermissionInfoMenusChildren.parentId = parentId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    getPermissionInfoMenusChildren.name = name;
  }
  final String? path = jsonConvert.convert<String>(json['path']);
  if (path != null) {
    getPermissionInfoMenusChildren.path = path;
  }
  final String? component = jsonConvert.convert<String>(json['component']);
  if (component != null) {
    getPermissionInfoMenusChildren.component = component;
  }
  final String? componentName = jsonConvert.convert<String>(json['componentName']);
  if (componentName != null) {
    getPermissionInfoMenusChildren.componentName = componentName;
  }
  final String? icon = jsonConvert.convert<String>(json['icon']);
  if (icon != null) {
    getPermissionInfoMenusChildren.icon = icon;
  }
  final bool? visible = jsonConvert.convert<bool>(json['visible']);
  if (visible != null) {
    getPermissionInfoMenusChildren.visible = visible;
  }
  final bool? keepAlive = jsonConvert.convert<bool>(json['keepAlive']);
  if (keepAlive != null) {
    getPermissionInfoMenusChildren.keepAlive = keepAlive;
  }
  final bool? alwaysShow = jsonConvert.convert<bool>(json['alwaysShow']);
  if (alwaysShow != null) {
    getPermissionInfoMenusChildren.alwaysShow = alwaysShow;
  }
  final dynamic children = json['children'];
  if (children != null) {
    getPermissionInfoMenusChildren.children = children;
  }
  return getPermissionInfoMenusChildren;
}

Map<String, dynamic> $GetPermissionInfoMenusChildrenToJson(GetPermissionInfoMenusChildren entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['parentId'] = entity.parentId;
  data['name'] = entity.name;
  data['path'] = entity.path;
  data['component'] = entity.component;
  data['componentName'] = entity.componentName;
  data['icon'] = entity.icon;
  data['visible'] = entity.visible;
  data['keepAlive'] = entity.keepAlive;
  data['alwaysShow'] = entity.alwaysShow;
  data['children'] = entity.children;
  return data;
}

extension GetPermissionInfoMenusChildrenExtension on GetPermissionInfoMenusChildren {
  GetPermissionInfoMenusChildren copyWith({
    int? id,
    int? parentId,
    String? name,
    String? path,
    String? component,
    String? componentName,
    String? icon,
    bool? visible,
    bool? keepAlive,
    bool? alwaysShow,
    dynamic children,
  }) {
    return GetPermissionInfoMenusChildren()
      ..id = id ?? this.id
      ..parentId = parentId ?? this.parentId
      ..name = name ?? this.name
      ..path = path ?? this.path
      ..component = component ?? this.component
      ..componentName = componentName ?? this.componentName
      ..icon = icon ?? this.icon
      ..visible = visible ?? this.visible
      ..keepAlive = keepAlive ?? this.keepAlive
      ..alwaysShow = alwaysShow ?? this.alwaysShow
      ..children = children ?? this.children;
  }
}